#!/bin/bash
if [ -f "arthas-boot.jar" ];then
   echo "arthas is exist"
else
   wget https://arthas.aliyun.com/arthas-boot.jar
fi

if [ -n "$1" ]; then
 echo "-------------get $1 process id start-------------------------------------------"
 ps -aux|grep $1
 echo "-------------get $1 process id end---------------------------------------------"
 echo "\n"
fi

echo "start arthas..."
if [ -n "$3" ]; then
   echo "use $2 , $3  port"
   export LD_LIBRARY_PATH=/home/ttx/app/jre/lib/amd64 &&/home/ttx/app/jre/bin/java -jar arthas-boot.jar --telnet-port $2 --http-port $3

elif [ -n "$2" ]; then
    echo "use $2  port"
   export LD_LIBRARY_PATH=/home/ttx/app/jre/lib/amd64 &&/home/ttx/app/jre/bin/java -jar arthas-boot.jar --telnet-port $2 

else
   echo "default"
   export LD_LIBRARY_PATH=/home/ttx/app/jre/lib/amd64 &&/home/ttx/app/jre/bin/java -jar arthas-boot.jar
fi
echo "done"
